package com.sali.schedule;

import cn.hutool.json.JSONUtil;
import com.sali.constants.CommonConstant;
import com.sali.entity.MockVO;
import com.sali.entity.NettyBean;
import com.sali.netty.NettyClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @description:
 * @author: sali
 * @date: 2025/2/22 下午11:23.
 * @version: 1.0
 */
@Component
@Slf4j
public class DataProduceSchedule {

    @Autowired
    private NettyClient nettyClient;

    @Scheduled(cron = "0/1 * * * * ?")
    public void handle() {
        MockVO mockVO = MockVO.builder()
                .mockIds(new String[]{"id1", "id2","1d3"})
                .mockType(1)
                .keywords(new String[]{"kw1", "kw2","kw3"}).build();
        String mockVOJson = JSONUtil.toJsonStr(mockVO);
        log.info("已向 netty client发送:{}", mockVOJson);
        nettyClient.sendData(new NettyBean(CommonConstant.BUSINESS_FLAG, mockVOJson));
    }
}
